<template>
  <div>
    <def-layout type="col0-24" :page="page" @invoke="invoke">
      <div slot="search" class="form-items">
        <el-form-item>
          <el-input v-model="formSearch.keyword" placeholder="采购单/退货单" />
        </el-form-item>
        <el-form-item>
          <el-input v-model="formSearch.supplierName" placeholder="供货商" />
        </el-form-item>
        <el-form-item>
          <el-select v-model="formSearch.supReturnStatus" placeholder="订单状态">
            <el-option
              v-for="item in constants.supReturnStatus.values()"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            />
          </el-select>
        </el-form-item>
        <el-form-item>
          <duty-users v-model="formSearch.consigneeId" size="mini" placeholder="接货员" mode="search" :duty-id="$store.state.settings.wmsConf.purchase.dutyId[2]" />
        </el-form-item>
      </div>
      <div slot="content" class="grid">
        <page-grid v-if="self!=null" :parent="self">
          <div slot="columns">
            <el-table-column prop="status" align="center" label="状态" width="150">
              <template slot-scope="scope">
                <column-filter v-model="scope.row.status" type="supReturnStatus" @click="filter" />
              </template>
            </el-table-column>
            <el-table-column prop="no" align="center" label="单号" width="200" />
            <el-table-column prop="supplierName" align="center" label="供应商" width="200" />
            <el-table-column prop="quantity" align="right" label="退货量(吨)" sortable width="120" />
            <el-table-column prop="totalAmount" align="right" label="货款总额" sortable width="150" />
            <el-table-column prop="createTime" sortable align="center" label="创建时间" width="150" />
            <el-table-column prop="updateTime" sortable align="center" label="更新时间" width="150" />
            <el-table-column prop="creator" align="center" label="创建人" width="150" />
            <el-table-column prop="updator" align="center" label="修改人" width="150" />
          </div>
        </page-grid>
      </div>
    </def-layout>

  </div>
</template>
<script>
import adminSupport from 'lola-admin-support-el'

export default {
  name: 'PurReturnOrderManage',
  components: {
  },
  mixins: [adminSupport.mixins.index],
  data() {
    return {
      name: 'PurReturnOrderManage',
      formSearch: { keyword: '', supplierName: '', supReturnStatus: 'All' },
      self: null
    }
  },
  created() {
    this.init()// 页面自定义初始化
  },
  methods: {
    init() {
      var that = this
      that.loadData()// 加载数据(按钮+列表) 扩展需重写该方法
      this.self = that
    },
    search() {
      const queryList = []
      if (!String.isNullOrEmpty(this.formSearch.supplierName)) {
        queryList.push({ 'key': 'o.name', 'value': {
          's.name': this.formSearch.supplierName,
          's.no': this.formSearch.supplierName
        }, 'oper': '=', 'join': 'andOr' })
      }
      if (!String.isNullOrEmpty(this.formSearch.keyword)) queryList.push({ 'key': 'o.no', 'value': this.formSearch.keyword, 'oper': '=', 'join': 'and' })
      if (!String.isNullOrEmpty(this.formSearch.supReturnStatus) && this.formSearch.supReturnStatus !== 'All') queryList.push({ 'key': 'o.status', 'value': this.formSearch.supReturnStatus, 'oper': '=', 'join': 'and' })
      this.dataGrid.params.queryList = queryList
      this.refresh()
    },
    bindSearch() {
      this.formSearch = { keyword: '', supplierName: '', supReturnStatus: '' }
    }
  }
}
</script>
